//index.js
Page({
  data: {
    list : []
  },
  login() {
    wx.login({
      success(res) {
        console.log(res.code);
        wx.request({
          // 需要配合本地服务器
          url: `http://127.0.0.1:8999/login?code=${res.code}`,
          success: (res) => {
            console.log(res.data.openid);
            wx.setStorage({
              data: res.data.openid,
              key: 'openId',
            })
          }
        })
      }
    })
  },
  onLoad() {
    wx.getStorage({
      key: 'openId',
      success: () => {
        console.log('已登录')
      },
      fail: () => {
        console.log('未登录')
      }    
    })
    console.log(this,'this.login();')
    wx.request({
      url: 'http://127.0.0.1:8999/',
      success: ({data}) => {
        console.log(data.data,'==');
        this.setData({
          list: data.data
        });
      }
    })
  }
})

















































































































































